Primitive Class Vec2
Represents a float-based 2D vector.
Members
x | (float) X component. |
y | (float) Y component. |
Functions
Vec2(x, y) | Create a Vec2 object. |
Vec(value) | Create a Vec2 object. |
__tostring(This) | Metafunction. |
Vec2:Normalize() | Get a copy of this Vec2 normalized to length 1. |
Vec2:Rotate(rot) | Get a copy of this Vec2 rotated by the input rotation in degrees. |
Vec2:Lerp(vector, alpha) | Get the linearly interpolated Vec2 between this Vec2 and the input Vec2 according to the input interpolation alpha. |
Vec2:Cross(vector) | Get the cross product of this Vec2 and the input Vec2. |
Vec2:Dot(vector) | Get the dot product of this Vec2 and the input Vec2. |
Vec2:Distance(vector) | Get the distance between this Vec2 and the input Vec2. |
Vec2:Length() | Get the length of this Vec2. |
Members
Functions
- Vec2(x, y)
-
Create a Vec2 object. (x, y)
Parameters:
- x float X component.
- y float Y component.
Returns:
-
Vec2
A new Vec2 object.
- Vec(value)
-
Create a Vec2 object. (value)
Parameters:
- value float X and Z component.
Returns:
-
Vec2
A new Vec2 object.
- __tostring(This)
-
Metafunction. Use tostring(vector).
Parameters:
- This Vec2 Vec2.
Returns:
-
string
A string showing the X and Y components of the Vec2.
- Vec2:Normalize()
-
Get a copy of this Vec2 normalized to length 1. ()
Returns:
-
Vec2
Normalized vector.
- Vec2:Rotate(rot)
-
Get a copy of this Vec2 rotated by the input rotation in degrees. (rot)
Parameters:
- rot float Rotation in degrees.
Returns:
-
Vec2
Rotated Vec2.
- Vec2:Lerp(vector, alpha)
-
Get the linearly interpolated Vec2 between this Vec2 and the input Vec2 according to the input interpolation alpha. (vector)
Parameters:
- vector Vec2 Target interpolation vector.
- alpha float Interpolation alpha in the range [0, 1].
Returns:
-
Vec2
Linearly interpolated vector
- Vec2:Cross(vector)
-
Get the cross product of this Vec2 and the input Vec2. (vector)
Parameters:
- vector Vec2 Input vector.
Returns:
-
Vec2
Cross product.
- Vec2:Dot(vector)
-
Get the dot product of this Vec2 and the input Vec2. (vector)
Parameters:
- vector Vec2 Input vector.
Returns:
-
float
Dot product.
- Vec2:Distance(vector)
-
Get the distance between this Vec2 and the input Vec2. (vector)
Parameters:
- vector Vec2 Input vector.
Returns:
-
float
Distance.
- Vec2:Length()
-
Get the length of this Vec2. ()
Returns:
-
float
Length.